package cn.kgc.springcloud.controller;

import cn.kgc.springcloud.service.SentinelService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author 课工场
 * @date 2024/7/26
 * @description
 */
@RestController
@RequestMapping("sentinel")
public class SentinelController {


    @Resource
    private SentinelService sentinelService;

    @GetMapping("m1")
    public String method1(){

        String s = sentinelService.method3();
        return "SentinelController method1 ok"+s;
    }

    @GetMapping("m2")
    public String method2(){

        String s = sentinelService.method3();
        return "SentinelController method2 ok"+s;
    }

    @GetMapping("m3")
    public String method3(){

        String info =  System.currentTimeMillis()+":请求正在排队...";
        System.out.println("info = " + info);
        return "SentinelController method3 ok";
    }


    @GetMapping("m4")
    public String method4(Integer id){

        if (id<0){
            throw  new RuntimeException();
        }

        return "SentinelController method4 ok";
    }


}
